package com.erp.collect.controller;

import java.util.List;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;

import com.ruoyi.common.core.annotation.RepeatSubmit;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.core.web.oldController.BaseController;
import com.ruoyi.common.core.web.oldPage.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.erp.collect.domain.vo.ErpKakaImgFenliVo;
import com.erp.collect.domain.bo.ErpKakaImgFenliBo;
import com.erp.collect.service.IErpKakaImgFenliService;

/**
 * kaka采集图片分离
 *
 * @author kaka
 * @date 2024-05-21
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/collect/kakaImgFenli")
public class ErpKakaImgFenliController extends BaseController {

    private final IErpKakaImgFenliService iErpKakaImgFenliService;

    /**
     * 查询kaka采集图片分离列表
     */
    @SaCheckPermission("collect:kakaImgFenli:list")
    @GetMapping("/list")
    public TableDataInfo<ErpKakaImgFenliVo> list(ErpKakaImgFenliBo bo, PageQuery pageQuery) {
        return iErpKakaImgFenliService.queryPageList(bo, pageQuery);
    }


    /**
     * 获取kaka采集图片分离详细信息
     *
     * @param id 主键
     */
    @SaCheckPermission("collect:kakaImgFenli:query")
    @GetMapping("/{id}")
    public R<ErpKakaImgFenliVo> getInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable Long id) {
        return R.ok(iErpKakaImgFenliService.queryById(id));
    }

    /**
     * 新增kaka采集图片分离
     */
    @SaCheckPermission("collect:kakaImgFenli:add")
    @Log(title = "kaka采集图片分离", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody ErpKakaImgFenliBo bo) {
        return toAjax(iErpKakaImgFenliService.insertByBo(bo));
    }

    /**
     * 修改kaka采集图片分离
     */
    @SaCheckPermission("collect:kakaImgFenli:edit")
    @Log(title = "kaka采集图片分离", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody ErpKakaImgFenliBo bo) {
        return toAjax(iErpKakaImgFenliService.updateByBo(bo));
    }

    /**
     * 删除kaka采集图片分离
     *
     * @param ids 主键串
     */
    @SaCheckPermission("collect:kakaImgFenli:remove")
    @Log(title = "kaka采集图片分离", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] ids) {
        return toAjax(iErpKakaImgFenliService.deleteWithValidByIds(Arrays.asList(ids), true));
    }
}
